/**
 * modelallowidlesconstraint.cpp is part of %PROJECTNAME%.
 *
 * %PROJECTNAME% is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * %PROJECTNAME% is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with %PROJECTNAME%.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "modelallowidlesconstraint.h"
#include "../../utils/visitor/visitor.h"
#include <sstream>

const std::string ModelAllowIdlesConstraint::ALLOW_IDLES_CONSTRAINT = "Allow idle";

ModelAllowIdlesConstraint::ModelAllowIdlesConstraint(  bool a_allowIdles ) :
    ModelConstraint(),
    m_allowIdles( a_allowIdles )
{
}

ModelAllowIdlesConstraint::~ModelAllowIdlesConstraint()
{
}

void ModelAllowIdlesConstraint::Accept( Visitor * a_visitor )
{
    if( a_visitor )
        a_visitor->Visit( this );
}

std::string ModelAllowIdlesConstraint::Print() const
{
    std::ostringstream strStream;
    std::string allowIdleStr = m_allowIdles ? "true" : "false";
    strStream << ALLOW_IDLES_CONSTRAINT << " = " << allowIdleStr;

    return strStream.str();
}

void ModelAllowIdlesConstraint::AllowIdles( bool a_allowIdles )
{
    m_allowIdles = a_allowIdles;
}

bool ModelAllowIdlesConstraint::AllowIdles() const
{
    return m_allowIdles;
}
